package ooday03;

public class RefArrayDemo {
    public static void main(String[] args) {
        Dog[] dogs=new Dog[5];//声明一个Dog型数组，共有五个数组元素，默认值是null，每个元素都是Dog型对象
        Chick[] chick=new Chick[6];//同类
        Fish[] fish=new Fish[9];//同类

        //给引用型数组的每个元素赋值也叫new对象;
        dogs[0]=new Dog("小白",34,"green");
        dogs[4]=new Dog("小黑",45,"black");

        dogs[0].name="小黄";
        dogs[4].name="小红";
        dogs[0].age=56;
        dogs[4].swim();

        for(int i=0;i<dogs.length;i++){
            dogs[i]=new Dog("xiaobai"+i,i*i,"i*i*i");
            System.out.println(dogs[i].name+dogs[i].color+dogs[i].age);
        }

        chick[5]=new Chick("麦当劳",43,"red");
        chick[3]=new Chick("KFC",56,"yellow");

        chick[5].name="麦麦";
        chick[3].name="布布";
        chick[3].layEggs();

        for(int i=0;i<chick.length;i++){
            chick[i]=new Chick("KFC"+i,i*i,"i"+i*3);
            System.out.println(chick[i].name+chick[i].age+chick[i].color);
        }


        fish[5]=new Fish("金枪鱼",23,"blue");
        fish[8]=new Fish("shark",78,"green");

        fish[5].color="grape";
        fish[8].name="blues";
        fish[5].swim();

        for(int i=1;i<fish.length;i++){
            fish[i]=new Fish("shark"+i,i*i*9,"i"+i*4);
            System.out.println(fish[i].name+fish[i].age+fish[i].color);
        }


    }
}
